Skip to content

feat(stovepipe): Persist terminal build identity - #746

Draft
prathshenoy wants to merge 1 commit into
mainfrom
prath.shenoy/stovepipe-project-result-build
Draft

prathshenoy wants to merge 1 commit into
mainfrom
prath.shenoy/stovepipe-project-result-build

Conversation

@prathshenoy

@prathshenoy prathshenoy commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

What:

  • Persist the winning terminal build ID on Request when a build reaches a terminal state.

Why:

  • Make the selected build direct operational state for downstream artifact resolution.
  • Preserve first-writer-wins semantics when concurrent builds complete.

Test Plan

  • Add unit tests.

Revert Plan

  • Revert this PR to remove the new Request field and restore the prior terminal-transition path. This is appropriate if no downstream consumer relies on the persisted build ID.

Issues

CODEM-514

@prathshenoy
prathshenoy force-pushed the prath.shenoy/stovepipe-project-result-build branch 3 times, most recently from 208831a to 66cef3f Compare September 25, 2026 03:19
@prathshenoy prathshenoy changed the title feat(stovepipe): Pass terminal build to project result resolver feat(stovepipe): Persist terminal build identity Sep 25, 2026
@prathshenoy
prathshenoy force-pushed the prath.shenoy/stovepipe-project-result-build branch 13 times, most recently from c354c8e to 9193d79 Compare September 28, 2026 15:47
@prathshenoy
prathshenoy marked this pull request as ready for review September 28, 2026 15:47
@prathshenoy
prathshenoy force-pushed the prath.shenoy/stovepipe-project-result-build branch from 9193d79 to c354c8e Compare September 28, 2026 16:24
}

if err := c.markOutcome(ctx, store, request, outcomeState(status)); err != nil {
log, err := c.markOutcome(ctx, store, request, outcomeState(status), buildID)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should persist the build info on either request (as a terminal build field) or on the build itself (as a boolean indicating which one is considered the terminal build) since either of those tables are for use as operational state.

Then, as part of persistOutcomeLog, you could still update the TerminalBuild field there as well (so it's available via API) and create a history event for it. However, these are projections for the view, and exist separately from the core operational flows.

// FinalizeOutcome atomically advances a Request to its terminal state and retains
// the matching state entry. Keeping the winning build id in that immutable entry
// means a crash cannot leave a terminal request without its selected build.
func (r *requestStore) FinalizeOutcome(ctx context.Context, request entity.Request, oldVersion, newVersion int32, log entity.RequestLog) (retErr error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After change above, can update the state of the the build, and then update the summary/logs as two steps which no longer need to be atomic.

@prathshenoy
prathshenoy force-pushed the prath.shenoy/stovepipe-project-result-build branch from c354c8e to b783b8f Compare September 28, 2026 22:23
@prathshenoy
prathshenoy requested a review from mnoah1 September 28, 2026 22:23
@prathshenoy
prathshenoy force-pushed the prath.shenoy/stovepipe-project-result-build branch 2 times, most recently from 17b670d to 75e62c0 Compare September 28, 2026 22:24
@prathshenoy
prathshenoy marked this pull request as draft September 28, 2026 22:25
@prathshenoy
prathshenoy force-pushed the prath.shenoy/stovepipe-project-result-build branch 8 times, most recently from 4748df4 to 039cf79 Compare September 28, 2026 22:43
Summary:
**What**:
- Persist the winning terminal build ID on Request when a build reaches a terminal state.

**Why**:
- Make the selected build direct operational state for downstream artifact resolution.
- Preserve first-writer-wins semantics when concurrent builds complete.

Test Plan:
- [x] `go test ./stovepipe/controller/buildsignal ./stovepipe/extension/storage/mysql`

Revert Plan:
- Revert this PR to remove the new Request field and restore the prior terminal-transition path. This is appropriate if no downstream consumer relies on the persisted build ID.

Jira Issues: None
@prathshenoy
prathshenoy force-pushed the prath.shenoy/stovepipe-project-result-build branch from 039cf79 to 55cc960 Compare September 29, 2026 00:58

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants